from lib.webui_permission import *


class c73254a:
    name = '产品管理员，验证所有界面存在且可操作左侧边栏部分-c73254a'  # 测试用例名字

    # 初始化方法
    def setup(self):
        STEP(1, '登陆网站')
        # 用超级管理员登录
        driver = open_browser()
        productor_login(driver)

    # 清除方法
    def teardown(self):
        driver = get_global_webdriver()
        driver.quit()

    # 测试用例步骤
    def teststeps(self):
        # 获取webdriver对象 对应 已经登录好的浏览器
        driver = get_global_webdriver()
        # driver = webdriver.Firefox()

        STEP(2, '输入超级管理员的账号和正确的密码，点击登录')
        extending_button = driver.find_element_by_id("hamburger-container")
        try:
            driver.find_element(By.CLASS_NAME, "el-tooltip")
            extending_button.click()
        except:
            print("左侧栏没有隐藏")
        # 记得改用户名，密码
        username2 = 'zhangsan'
        got_username2 = driver.find_element(By.CSS_SELECTOR,
                                                 ".avatar-wrapper > span:nth-child(1)").text
        CHECK_POINT("id是否正确", username2 == got_username2)
        got_list2 = []
        time.sleep(1)
        product_word2 = driver.find_element(By.XPATH,
                                                 "/html/body/div/div/div[1]/ul/div[1]/a/li/span"
                                            )
        got_list2.append(product_word2.text)
        product_word2.click()
        time.sleep(1)
        top_title0 = driver.find_element(By.XPATH,
                                         "/html/body/div/div/div[2]/div/div/div[2]/span/span/span[1]/span"
                                         ).text
        CHECK_POINT("上方第1个标题对应","产品列表" == top_title0)

        time.sleep(1)
        apply_word2 = driver.find_element(By.XPATH,
                                             "/html/body/div/div/div[1]/ul/div[2]/a/li/span"
                                               )
        got_list2.append(apply_word2.text)
        apply_word2.click()
        time.sleep(1)
        top_title1 = driver.find_element(By.XPATH,
                                         "/html/body/div/div/div[2]/div/div/div[2]/span/span[2]/span[1]/span"
                                          ).text
        CHECK_POINT("上方第2个标题对应", "申请记录" == top_title1)

        time.sleep(1)
        product_manage_word2 = driver.find_element(By.XPATH,
                                                   "/html/body/div/div/div[1]/ul/div[3]/a/li/span"
                                                       )
        got_list2.append(product_manage_word2.text)
        product_manage_word2.click()
        time.sleep(1)
        top_title2 = driver.find_element(By.XPATH,
                                         "/html/body/div/div/div[2]/div/div/div[2]/span/span[2]/span[1]/span"
                                          ).text
        CHECK_POINT("上方第3个标题对应", "产品管理" == top_title2)

        expetced_word_list2 = ["产品列表", "申请记录", "产品管理"]
        CHECK_POINT("验证是否为期待文字列表", expetced_word_list2 == got_list2)

